package Year22_Month03.day19;

import java.util.Arrays;

public class Gift {
    public int getValue(int[] gifts, int n) {
        Arrays.sort(gifts);
        int count = 0;
        int ans = gifts[(n - 1) / 2];
        for (int i = 0; i < gifts.length; i++) {
            if(gifts[i] == ans){
                count++;
            }
        }
        return count > gifts.length/2 ? gifts[(n-1) /2] : 0;
    }
}
